home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Newton Sample Code 1.2 / Routing / SendCard-2 / sendCard.text < prev    next >
Encoding:
Text File  |  1994-02-28  |  4.2 KB  |  142 lines  |  [TEXT/MPS ]

  1. constant kAppSymbol := '|sendCard:PIEDTS|;
  2. constant kMyItemIDRoutingSymbol := '|ID:sendCard:PIEDTS|;
  3. constant kMyTotalItemsRoutingSymbol := '|total:sendCard:PIEDTS|;
  4.  
  5.  
  6. installScript := func(partFrame)
  7. begin
  8.    routing.(kAppSymbol) := partFrame.theForm.myRoutingFrame ;
  9. end;
  10.  
  11. removeScript := func(partFrame)
  12. begin
  13.    RemoveSlot(routing, kAppSymbol);
  14. end;
  15. // ---- End Project Data ----
  16.  
  17.  
  18. // ---- File main.t ----
  19.  
  20. // Before Script for "myBase"
  21. // Copyright 1993-1994 Apple Computer. All rights reserved.
  22.  
  23. myBase :=
  24.    {viewBounds: {left: -12, top: 38, right: 176, bottom: 122},
  25.     appSymbol: kAppSymbol,
  26.     myRoutingFrame:
  27.       {
  28.          // very simple routing frame, just doing beaming
  29.       
  30.          beam: {
  31.             title: "Beam Em!",
  32.             routeForm: 'zapSlip
  33.          }
  34.       },
  35.     setupRoutingSlip:
  36.       func(fields)
  37.       begin
  38.          // message sent after the user hits Beam in zapSlip
  39.       
  40.          // set the recieving applicaiton to be the card file
  41.          fields.appSymbol := 'cardFile;
  42.       
  43.          fields.(kMyItemIDRoutingSymbol) := 1 ;
  44.       
  45.          // Now send over up to 2 more cards as seperate beams
  46.          local num := 0 ; // the first beam
  47.          local myFieldsArray := [] ;
  48.          local temp ;
  49.       
  50.          while myCursor:Next() and (num < 3) do
  51.          begin
  52.             num := num + 1 ;
  53.             // make a clone of the fields variable. This is the
  54.             // data structure that is sent over on the beam
  55.             temp := TotalClone(fields);
  56.       
  57.             // the putAway script on the other side actually
  58.             // looks at the body slot not the target slot
  59.             // so put the real data into the body slot
  60.             temp.body := myCursor:Entry();
  61.       
  62.             // now add some information for synchronization
  63.             // i.e., this is the nth item.
  64.             temp.(kMyItemIDRoutingSymbol) := num ;
  65.       
  66.             // finally, add the item to the array of items that
  67.             // will get jammed into the outbox
  68.             AddArraySlot(myFieldsArray, temp) ;
  69.          end;
  70.       
  71.       
  72.          // now post the items to the outbox
  73.          foreach item in myFieldsArray do
  74.          begin
  75.             // add more synchronization information, in this
  76.             // case the total number of items that are in
  77.             // the 'beam'
  78.             item.(kMyTotalItemsRoutingSymbol) := num ;
  79.       
  80.             // set the title of the item for the out/inbox
  81.             item.title := "Send Card" && item.(kMyItemIDRoutingSymbol) && "of" && num ;
  82.       
  83.             // jam it in the outbox
  84.             outbox:PostItem(item); // submit
  85.          end;
  86.       
  87.       
  88.          fields.(kMyItemIDRoutingSymbol) := num ;
  89.          // setup the title that will show in the
  90.          // outbox item. NOTE: the outbox does not wrap
  91.          // it will let you overwrite the line below
  92.          fields.title := "Send Card 1 of" && num;
  93.       end,
  94.     title: "Send Card",
  95.     viewSetupDoneScript:
  96.       func()
  97.       begin
  98.          // setup the routing information
  99.        
  100.          myCursor := Query(GetUnionSoup(ROM_cardfilesoupname),
  101.                            {type: 'index, indexPath: 'sortOn}) ;
  102.       
  103.          // the target data for the route, this would normally be
  104.          // a cursor Entry. If you want to do mailing, beaming
  105.          // deleting, ... this MUST be a cursor entry.
  106.          self.target :=  myCursor:Entry();
  107.          
  108.          // view that gets the routing messages
  109.          self.targetView := self ;
  110.       end,
  111.     myCursor: nil,
  112.     viewQuitScript:
  113.       func()
  114.       begin
  115.       myCursor := nil;      // you must nil out your cursor in your quit script or else you can
  116.                           // get errors relating to bad reference when you try to take out the card.
  117.                           // errors like this are very difficult to track down, so nil out your cursors!
  118.       end,
  119.     _proto: protoFloatNGo,
  120.     debug: "myBase"
  121.    };
  122.  
  123. _view000 := /* child of myBase */
  124.    {viewBounds: {left: 6, top: 8, right: 78, bottom: 24}, _proto: protoTitle};
  125.  
  126.  
  127.  
  128. _view001 := /* child of myBase */
  129.    {viewJustify: 166,
  130.     viewBounds: {left: -44, top: -20, right: -27, bottom: -7},
  131.     _proto: protoActionButton
  132.    };
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. // ---- Beginning of section for non used Layout files ----
  141.  
  142. // End of output